package com.common.util;

import org.springframework.data.domain.Page;

public class TablePage<T> {
	private Integer page;
	private Long total;
	private T rows;

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Long getTotal() {
		return total;
	}

	public void setTotal(Long total) {
		this.total = total;
	}

	public T getRows() {
		return rows;
	}

	public void setRows(T rows) {
		this.rows = rows;
	}

	public static TablePage getTablePage(Page page) {
		TablePage result = new TablePage();
		if (page != null) {
			result.setPage(page.getNumber());
			result.setRows(page.getContent());
			result.setTotal(page.getTotalElements());
		}
		return result;
	}
}
